<?php
namespace app\spadmin\controller\education;
use app\common\controller\Backend;
/**
 * 学科类目
 */
class Subject extends Backend{

    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('Subject');
    }

    public function index(){
        $this->request->filter(['strip_tags', 'trim']);
        
        if($this->request->isAjax()){
            $data = $this->request->param();
            if (isset($data['keywords']) && $data['keywords']) {
                $map['name'] = ['like','%'.$data['keywords'].'%'];
            }
                     
            if (isset($data['status']) && $data['status'] === '0') {
                $map['status'] = $data['status'];
            } else {
                $map['status'] = 1;
            }     
            $list =   $this->model->where($map)->order('sort asc')->paginate($data['limit']);
            foreach ($list as &$li) {
                $li->toArray();
            }
            return $this->result($list);
        }
        return $this->view->fetch();
    }
    
}